import * as type from './type'

import axios from 'axios'

const state={
    dutyfreedata:null
}

export const actionCreators={
    get_duty_free(){
        return dispatch=>{
            axios({
                url:'/mock/data_dutyfree.json'
            })
            .then(data=>{
                const action={
                    type:type.GET_DUTYFREE_DATA,
                    payload:data.data
                }
                dispatch(action)
            })
            .catch(error=>console.log(error))

        }
    }
}

export const reducer=(previousState=state,action)=>{
    const newState={
        ...previousState
    }
    switch(action.type){
        case type.GET_DUTYFREE_DATA:
            newState.dutyfreedata=action.payload
        break;
        default:
            break;
    }
    return newState;
}